﻿using System;
using ICSharpCode.AvalonEdit;
using Oxage.Models;
using Oxage.Views;

namespace Oxage.Services
{
	public class TextEditorService
	{
		private static TextEditor activeTextEditor;
		public static TextEditor ActiveTextEditor
		{
			get
			{
				return activeTextEditor;
			}
			set
			{
				if (activeTextEditor != value)
				{
					var oldValue = activeTextEditor;
					activeTextEditor = value;
					OnActiveTextEditorChanged(oldValue, value);
				}
			}
		}

		public static event EventHandler<NewValueEventArgs<TextEditor>> ActiveTextEditorChanged;
		private static void OnActiveTextEditorChanged(TextEditor oldValue, TextEditor newValue)
		{
			if (ActiveTextEditorChanged != null)
			{
				ActiveTextEditorChanged(null, new NewValueEventArgs<TextEditor>(oldValue, newValue));
			}
		}

		public static EditorView Editor { get; set; }
	}
}
